package com.xypw.models;

import java.util.HashMap;
import java.util.List;

import com.et.ar.ActiveRecordBase;
import com.et.ar.annotations.Column;
import com.et.ar.annotations.Id;
import com.et.ar.annotations.Table;
import com.et.ar.exception.ActiveRecordException;

@Table(name="tb_industry")
public class Industry extends ActiveRecordBase{
	@Id
	private int id;
	@Column
	private String code;
	@Column
	private String industryName;
	private static HashMap<String, String> map;
	private static List<Industry> list;
	static{
		if(map==null){
			map = new  HashMap<String, String>();
			try {
				list = ActiveRecordBase.findAll(Industry.class);
				for (Industry industry : list) {
					map.put(industry.getCode(), industry.getIndustryName());
				}
			} catch (ActiveRecordException e) {
				e.printStackTrace();
			}
		}
	}
	public static String getIndustryName(String key){
		String name= "其他部门";
		if(map.get(key) != null && !"".equals(map.get(key))){
			name = map.get(key);
		}
		return name;
	}

	public static List<Industry> getAllIndustry(){
		return list;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getId() {
		return id;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getCode() {
		return code;
	}

	public void setIndustryName(String industryName) {
		this.industryName = industryName;
	}

	public String getIndustryName() {
		return industryName;
	}
	
}
